
const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
const Version = 'v=' + new Date().getTime()

//加入
module.exports = {
  outputDir: 'flow',
  transpileDependencies: true,
  productionSourceMap: false,
  publicPath: process.env.BASE_URL,
  configureWebpack: {
    plugins: [
      AutoImport({
        resolvers: [ElementPlusResolver()],
      }),
      Components({
        resolvers: [ElementPlusResolver()],
      })
    ],
    externals: {
      AWSC: 'AWSC'
    },
    output: {
      filename: `js/[name].${Version}.js`,         // js打包文件，添加时间戳
      chunkFilename: `js/[name].${Version}.js`
    }
  },
  css: {
    loaderOptions: {
      scss: {
        additionalData: `
        @import "@ruifox-cms/styles/index.scss";
        @import "@/styles/index.scss";
        `
      }
    },
    extract: {
      filename: `css/[name].${Version}.css`,
      chunkFilename: `css/[name].${Version}.css`
    }
  },
  devServer: {
    // disableHostCheck: true,
    port: 8102,
    client: {
      overlay: false
    },
    proxy: {
        '/admin_api': {
            target: process.env.VUE_APP_BASE_API,
            changeOrigin: true,
            ws: true,
            pathRewrite: {
                '^/admin_api': ''
            },
            onProxyReq(proxyReq){
              proxyReq.removeHeader('origin') 
            }
        }
    }
  }
}
